import { WeaDialog, WeaInput, WeaLocaleProvider } from 'ecCom';
import { Button } from 'antd';
import CoworkConstant from '../../../util/CoworkConstant';
import { inject, observer } from 'mobx-react';

const getLabel = WeaLocaleProvider.getLabel;

@inject('coworkMainStore')
@observer
class CoworkFloorDialog extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      visible: false,
    };
  }
  render() {
    let { visible } = this.state;
    const { coworkMainStore } = this.props,
{ content } = coworkMainStore,
{ searchForm } = content;
    let { srchFloorNum } = searchForm.getFormParams();
    return (
      <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@26ieg0`}
        style={{ width: 200, height: 60 }}
        visible={visible}
        title={getLabel(382632, '跳转楼层')}
        icon={CoworkConstant.iconClassName}
        iconBgcolor={CoworkConstant.iconBgColor}
        onCancel={this.back}
        buttons={[
                   <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@f21mip@onok`} onClick={this.submit}>{getLabel(16631, '确认')}</Button>,
                   <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@qpj6fk@return`} onClick={this.back}>{getLabel(1290, '返回')}</Button>,
                 ]}
      >
        <div className="pt20">
          <div className="ant-col-4" />
          <label className="ant-col-8" style={{ lineHeight: '28px' }} htmlFor={'weainput'}>{getLabel(382633, '输入楼层：')}</label>
          <div className="ant-col-8" >
            <WeaInput ecId={`${this && this.props && this.props.ecId || ''}_WeaInput@jv5x1b`} value={srchFloorNum} onChange={this.setFloorNum} />
          </div>
          <div className="ant-col-4" />
        </div>
      </WeaDialog>
    );
  }
  open = () => {
    this.setState({
      visible: true,
    });
  }

  submit = () => {
    const { coworkMainStore } = this.props,
searchForm = coworkMainStore.content.searchForm;
    coworkMainStore.searchDiscussList(searchForm.getFormParams());
    this.back();
  }

  back = () => {
    this.setState({
      visible: false,
    });
  }

  setFloorNum = (floorNum) => {
    const { coworkMainStore } = this.props,
{ content } = coworkMainStore,
{ searchForm } = content;
    searchForm.updateFields({ srchFloorNum: { value: floorNum || '' } });
  }
}

export default CoworkFloorDialog;
